package com.yanqu.road.entity.rank.cross;

import com.alibaba.fastjson.JSON;
import com.yanqu.road.entity.DataObject;
import com.yanqu.road.entity.union.UnionBaseInfo;

import java.math.BigInteger;
import java.util.Objects;

public class CrossUnionWeekRank extends DataObject {

    private int rank;                             //名次

    private long serverId;

    private int weekId;

    private String unionUid;                      //商会Id

    private UnionBaseInfo unionBaseInfo = new UnionBaseInfo();

    private long lastUpdateTime;                  //最后一次更新时间

    private BigInteger value = BigInteger.ZERO;  //排名数据

    private String param = "";

    private int type;

    public int getRank() {
        return rank;
    }

    public void setRank(int rank) {
        if(this.rank != rank) {
            this.rank = rank;
            setUpdateOption();
        }
    }

    public String getUnionUid() {
        return unionUid;
    }

    public void setUnionUid(String unionUid) {
        if (unionUid == null) {
            return;
        }
        if (!unionUid.equals(this.unionUid)) {
            this.unionUid = unionUid;
            setUpdateOption();
        }
    }

    public UnionBaseInfo getUnionBaseInfo() {
        return unionBaseInfo;
    }

    public String getUnionBaseInfoJsonStr(){
        if(null == unionBaseInfo){
            return "{}";
        }else {
            return JSON.toJSONString(unionBaseInfo);
        }
    }

    public void setUnionBaseInfo(UnionBaseInfo unionBaseInfo) {
        this.unionBaseInfo = unionBaseInfo;
        setUpdateOption();
    }

    public BigInteger getValue() {
        return value;
    }

    public void setValue(BigInteger value) {
        if(!Objects.equals(this.value, value)) {
            this.value = value;
            setUpdateOption();
        }
    }

    public long getLastUpdateTime() {
        return lastUpdateTime;
    }

    public void setLastUpdateTime(long lastUpdateTime) {
        if(this.lastUpdateTime != lastUpdateTime) {
            this.lastUpdateTime = lastUpdateTime;
            setUpdateOption();
        }
    }

    public String getParam() {
        return param;
    }

    public void setParam(String param) {
        if (param == null) {
            return;
        }
        if (!this.param.equals(param)) {
            this.param = param;
            setUpdateOption();
        }

    }

    public long getServerId() {
        return serverId;
    }

    public void setServerId(long serverId) {
        this.serverId = serverId;
    }

    public int getWeekId() {
        return weekId;
    }

    public void setWeekId(int weekId) {
        this.weekId = weekId;
    }

    public int getType() {
        return type;
    }

    public void setType(int type) {
        this.type = type;
    }

    public CrossUnionWeekRank clone(){
        CrossUnionWeekRank unionRank = new CrossUnionWeekRank();
        unionRank.setUnionUid(unionUid);
        unionRank.setUnionBaseInfo(unionBaseInfo);
        unionRank.setValue(value);
        unionRank.setLastUpdateTime(lastUpdateTime);
        unionRank.setServerId(serverId);
        unionRank.setWeekId(weekId);
        unionRank.setType(type);
        unionRank.setParam(param);
        return unionRank;
    }
}
